package realQuestion.jingDong8_19;

import java.util.Scanner;

public class  Test3 {


}

class  Mian1{

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        char[][] board = new char[n][m];
        for (int i = 0; i < n; i++) {
            String line = scanner.nextLine();

            for (int j = 0; j < m; j++) {
                board[i][j] = line.charAt(j);
            }
        }
        int i = find(board);
        System.out.println(i);

    }

    static  int find(char[][] board){
        int n = board.length;
        int m = board[0].length;
        int[][] dp = new int[n][m];
        dp[0][0]=0;
        for (int i = 1; i <n ; i++) {
            if (board[i][0]=='*'){
                dp[i][0]=-1;
            }else {
                dp[i][0]=dp[i-1][0]+1;
            }

        }
        for (int j = 0; j < m; j++) {
            if (board[0][j]=='*'){
                dp[0][j]=-1;
            }else {
                dp[0][j]=dp[0][j-1]+1;
            }
        }

        for (int i = 1; i < n; i++) {
            for (int j = 1; j <m ; j++) {
                if (board[i][j]=='*'){
                    dp[i][j]=-1;
                }else {
                    int min1=dp[i-1][j];
                    int min2=dp[i][j-1];
                    int min3=dp[i-1][j-1];

                    if (min1==-1&&min2==-1&&min3==-1){
                        dp[i][j]=-1;
                    }else {
                        dp[i][j]=Math.min(Math.min(min1,min2),min3)+1;
                    }
                }

            }
        }

        return  dp[n-1][m-1];

        }


}